<template>
  <a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" >
    <a-form-item label="用户名">
      <a-input v-model="account"  aria-placeholder="请输入用户名"
      />
    </a-form-item>
    <a-form-item label="密码">
       <a-input v-model="pwd" aria-placeholder="请输入密码"
      />
    </a-form-item>
    <a-form-item :wrapper-col="{ span: 12, offset: 5 }">
      <a-button type="primary" @click="login" >
        登录
      </a-button>
    </a-form-item>
  </a-form>
</template>

<script>


import axios from 'axios'  ; //导入 axios'

axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

import Qs from 'qs'
import Api from '@/api/request.js'

 
export default {
  data() {
    return {
      account:'',
      pwd:'',
      data:''
    }
  },
  created:function(){
    console.log("第一次");
  },
  methods: {
    login:function(){
      console.log(this.account+"  "+ this.pwd);
        var _this = this;
         let data= {
           account: this.account,
           pwd: this.pwd
         };

  //如果说直接写成这样 /adminManage/admin/login，它所带的端口号和ip地址 是 当前所在项目的ip地址和端口号 
  // "adminManage/admin/login"
  axios.post(Api.api.login, Qs.stringify(data)
  ).then((res) =>  {
      　　this.data=res.data;
          if(this.data.result != null ){
          console.log(this.data.result.empId);
          this.$router.push({path:'/index',params:{setid:111222}});
          }else{
            alert("请重新登录")
          }
       })


  
    }
  }
}
</script>